package com.cskaoyan.dbutils.resultsetHandler;

import org.apache.commons.dbutils.ResultSetHandler;

import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.HashMap;

/**
 * 创建日期: 2022/11/18 17:19
 *
 * @author ciggar
 */
public class MyResultSetHandler implements ResultSetHandler {

    @Override
    public Object handle(ResultSet resultSet) throws SQLException {

        boolean ret = resultSet.next();
        if (!ret) return null;

        int id = resultSet.getInt("id");
        String name = resultSet.getString("name");
        int money = resultSet.getInt("money");

        HashMap<String, Object> hashMap = new HashMap<>();
        hashMap.put("id",id);
        hashMap.put("name",name);
        hashMap.put("money",money);

        return hashMap;
    }
}
